import grails.test.*
import java.util.Date

class EmployeeTests extends GrailsUnitTestCase {
    protected void setUp() {
        super.setUp()
    }

    protected void tearDown() {
        super.tearDown()
    }

    void testEmployeeInstanziation() {
        Employee emp = new Employee(firstName: "Johan", lastName: "Johansson", street: "Vasavägen",
                                    city: "Linköping", zipCode: 55555, dob: new Date(1972,07,22), email: "johan.johansson@gmail.com",
                                    userName: "johan.johansson", password: "12345", passwordVerify: "12345", title: "Mr", employeeId: 32)

        assertEquals emp.firstName, "Johan"
        assertEquals emp.lastName, "Johansson"
        assertEquals emp.street, "Vasavägen"
        assertEquals emp.city, "Linköping"
        assertEquals emp.zipCode, 55555
        assertEquals emp.dob, new Date(1972,07,22)
        assertEquals emp.email, "johan.johansson@gmail.com"
        assertEquals emp.userName, "johan.johansson"
        assertEquals emp.password, "12345"
        assertEquals emp.passwordVerify, "12345"
        assertEquals emp.title, "Mr"
        assertEquals emp.employeeId, 32
    }

    void testGetWorkingHoursPerYear()
    {
        Employee emp1 = new Employee(firstName: "Johanna", lastName: "Johannasson", street: "Vasavägen",
                                    city: "Linköping", zipCode: 55555, dob: new Date(1972,07,22), email: "johanna.johannasson@gmail.com",
                                    userName: "johanna.johannasson", password: "12345", passwordVerify: "12345", title: "Mr", percentageWork: "100", employeeId: 33)

        Employee emp2 = new Employee(firstName: "Lars", lastName: "Larsson", street: "Vasavägen",
                                    city: "Linköping", zipCode: 55555, dob: new Date(1952,07,22), email: "lars.larsson@gmail.com",
                                    userName: "lars.larsson", password: "12346", passwordVerify: "12346", title: "Mr", percentageWork: "100", employeeId: 35)

        assertEquals emp1.getWorkingHoursPerYear(), 1732
        assertEquals emp2.getWorkingHoursPerYear(), 1700
        
    }

    void testEmployeeToString()
    {
        Employee emp = new Employee(firstName: "Lars", lastName: "Larsson", street: "Vasavägen",
                                    city: "Linköping", zipCode: 55555, dob: new Date(1952,07,22), email: "lars.larsson@gmail.com",
                                    userName: "lars.larsson", password: "12345", passwordVerify: "12345", title: "Mr", percentageWork: "100", employeeId: 36)

        assertEquals emp.toString, "Lars Larsson, (lars.larsson)"

    }
}
